#include "Precomp.h"
#include "Text.h"

Text::Text()
:Entity(Entity::TEXT)
{
	shape=&shape_impl;
	size.x=shape_impl.GetRect().GetWidth();
	size.y=shape_impl.GetRect().GetHeight();
	init();
}

const SQChar* Text::getText() const
{
	return text.c_str();
}

void Text::setText(const SQChar* text)
{
	//this->text=text;
	shape_impl.SetText(text);
	size.x=shape_impl.GetRect().GetWidth();
	size.y=shape_impl.GetRect().GetHeight();
}

void Text::serialize(SquirrelObject& out) const
{
	Entity::serialize(out);
	out.SetValue(L"text",getText());
}

void Text::deserialize(SquirrelObject& in)
{
	Entity::deserialize(in);
	setText(in.GetString(L"text"));
}